Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. pw::transfer::internal::TransferThread Class Reference
Loading...
Searching...
No Matches
pw::transfer::internal::TransferThread Class Reference
Inheritance diagram for pw::transfer::internal::TransferThread:
pw::transfer::Thread< kMaxConcurrentClientTransfers, kMaxConcurrentServerTransfers >

Public Member Functions

 TransferThread (span< ClientContext > client_transfers, span< ServerContext > server_transfers, ByteSpan chunk_buffer, ByteSpan encode_buffer)
 
void SetServerCompletionCallback (pw::Function< void(uint32_t, pw::Status)> &&cb)
 
void NotifyServerCompletion (uint32_t session_id, Status status)
 
void StartClientTransfer (TransferType type, ProtocolVersion version, uint32_t resource_id, uint32_t handle_id, stream::Stream *stream, const TransferParameters &max_parameters, Function< void(Status)> &&on_completion, chrono::SystemClock::duration timeout, chrono::SystemClock::duration initial_timeout, uint8_t max_retries, uint32_t max_lifetime_retries, uint32_t initial_offset=0)
 
void StartServerTransfer (TransferType type, ProtocolVersion version, uint32_t session_id, uint32_t resource_id, ConstByteSpan raw_chunk, const TransferParameters &max_parameters, chrono::SystemClock::duration timeout, uint8_t max_retries, uint32_t max_lifetime_retries, uint32_t initial_offset=0)
 
void ProcessClientChunk (ConstByteSpan chunk)
 
void ProcessServerChunk (ConstByteSpan chunk)
 
void SendServerStatus (TransferType type, uint32_t session_id, ProtocolVersion version, Status status)
 
void CancelClientTransfer (uint32_t handle_id)
 
void EndClientTransfer (uint32_t session_id, Status status, bool send_status_chunk=false)
 
void EndServerTransfer (uint32_t session_id, Status status, bool send_status_chunk=false)
 
void SetClientReadStream (rpc::RawClientReaderWriter &read_stream, Client *client, Function< void(ConstByteSpan)> &&on_next, internal::SetStreamBehavior behavior)
 
void CloseClientReadStream (Client *client)
 
void SetClientWriteStream (rpc::RawClientReaderWriter &write_stream, Client *client, Function< void(ConstByteSpan)> &&on_next, internal::SetStreamBehavior behavior)
 
void CloseClientWriteStream (Client *client)
 
void SetServerReadStream (rpc::RawServerReaderWriter &read_stream, Function< void(ConstByteSpan)> &&on_next)
 
void SetServerWriteStream (rpc::RawServerReaderWriter &write_stream, Function< void(ConstByteSpan)> &&on_next)
 
bool AddTransferHandler (Handler &handler)
 
bool RemoveTransferHandler (Handler &handler)
 
size_t max_chunk_size () const
 
void Terminate ()
 
void WaitUntilEventIsProcessed ()
 
void SimulateClientTimeout (uint32_t session_id)
 
void SimulateServerTimeout (uint32_t session_id)
 
void EnqueueResourceEvent (uint32_t resource_id, ResourceStatusCallback &&callback)
 

Friends

class transfer::Client
 
class Context
 

Member Function Documentation

◆ SetClientReadStream()

void pw::transfer::internal::TransferThread::SetClientReadStream ( rpc::RawClientReaderWriter &  read_stream,
Client *  client,
Function< void(ConstByteSpan)> &&  on_next,
internal::SetStreamBehavior  behavior 
)

Updates the transfer thread's client read stream.

The provided stream should not have an on_next function set. Instead, on_next is passed separately to ensure that it is only set when the new stream becomes the transfer thread's primary stream.

If the thread has an existing active client read stream, closes it and terminates any transfers running on it.

◆ SetClientWriteStream()

void pw::transfer::internal::TransferThread::SetClientWriteStream ( rpc::RawClientReaderWriter &  write_stream,
Client *  client,
Function< void(ConstByteSpan)> &&  on_next,
internal::SetStreamBehavior  behavior 
)

Updates the transfer thread's client write stream.

The provided stream should not have an on_next function set. Instead, on_next is passed separately to ensure that it is only set when the new stream becomes the transfer thread's primary stream.

If the thread has an existing active client write stream, closes it and terminates any transfers running on it.

◆ SetServerCompletionCallback()

void pw::transfer::internal::TransferThread::SetServerCompletionCallback ( pw::Function< void(uint32_t, pw::Status)> &&  cb)
inline

Set callback to be invoked when a server-side transfer completes or fails.

Warning
This callback is invoked from the transfer thread, so the callback:
  1. Must not attempt to interact with the transfer thread, as doing so can cause deadlock or internal state corruption.
  2. Must return quickly to avoid stalling the transfer thread or the rpc thread.

◆ SetServerReadStream()

void pw::transfer::internal::TransferThread::SetServerReadStream ( rpc::RawServerReaderWriter &  read_stream,
Function< void(ConstByteSpan)> &&  on_next 
)

Updates the transfer thread's server read stream.

The provided stream should not have an on_next function set. Instead, on_next is passed separately to ensure that it is only set when the new stream becomes the transfer thread's primary stream.

If the thread has an existing active server read stream, closes it and terminates any transfers running on it.

◆ SetServerWriteStream()

void pw::transfer::internal::TransferThread::SetServerWriteStream ( rpc::RawServerReaderWriter &  write_stream,
Function< void(ConstByteSpan)> &&  on_next 
)

Updates the transfer thread's server write stream.

The provided stream should not have an on_next function set. Instead, on_next is passed separately to ensure that it is only set when the new stream becomes the transfer thread's primary stream.

If the thread has an existing active server write stream, closes it and terminates any transfers running on it.


The documentation for this class was generated from the following file: